<?php
require_once('../../../wp-load.php');
require_once('includes/class.phpmailer.php');

function accs_email_settings($type){
	
	//TODO: replace this with info from PLUGIN SETTINGS
	//this way they will be able to edit the seetings!!

	//I assume there is only two types of emails at this
	//point. the daily and then the weekly.

	$subject = 'Unknown Email Type';

	switch($type){
		case 'daily': 
			$subject = 'daily subject';
			break;
		case 'weekly': 
			$subject = 'daily subject';
			break;
	}		

	$settings = array(
		'mail-debug' => 2,
		'mail-auth'  => true,
		'mail-secure' => 'ssl',
		'mail-host' => 'smtp.gmail.com',
		'mail-port' => 465,
		'mail-username' => 'rollinscollegetest@gmail.com',
		'mail-password' => 'r0ll1nstest',
		'mail-from' => 'donotreply@rollins.edu',
		'mail-from-name' => 'Your Favorite College!!!',
		'mail-subject' => $subject,
		'mail-alt-body' => 'To view the message, please use an HTML compatible email viewer!'
	);
	return $settings;
}

function email_html()
{
	return '
<html><body bgcolor="#ddd5b3" style="font:Arial, Helvetica, sans-serif; color: #4e3227;"><table id="main" width="800px"><tbody><tr><td colspan="3" bgcolor="#002c5f"><table id="topRow" height="50px"><tbody><tr><td width="100%" colspan="3"><!--THIS WILL BE THE LINK TO THE LOGO--><img src="/wp-content/themes/rollins_accs/images/Rollins_Horizontal.png" style="float:left" height="30"><h2 style="font:Arial; font-size:28px; color:#ddd5b3; padding-left:10px; padding-top:20px; display:inline">Good Morning, Rollins!</h2></td></tr></tbody></table></td></tr><tr><td valign="top"><table id="" width="150px"><tbody><tr><td valign="top" style="font:Arial, Helvetica, sans-serif; font-weight:normal; font-size:12px;" bgcolor="#c8bb8a"><span style="font-size:14px; font-weight:bold; display:block;">Library Taken Over by Zombies</span><br/>Awesome Announcement</td></tr></tbody></table></td><td valign="top"><table id="" width="150px"><tbody><tr><td valign="top" style="font:Arial, Helvetica, sans-serif; font-weight:normal; font-size:12px;" bgcolor="#c8bb8a"><span style="font-size:14px; font-weight:bold; display:block;">A Free Beer for Every Letter Grade of A</span>Awesome Promotion</td></tr></tbody></table></td><td valign="top"><table id="" width="150px"><tbody><tr><td valign="top" style="font:Arial, Helvetica, sans-serif; font-weight:normal; font-size:12px;"><span style="font-size:14px; font-weight:bold; display:block;padding-bottom:5px;">Graduation - Myth or Reality</span>Awesome Event</td></tr></tbody></table></td></tr><tr><td colspan="3" bgcolor="#002c5f" height="30px;"></td></tr></tbody></table></body></html>
	';
}


function send_email(){

	$type = 'daily'; //differentiate between email types???
	$settings = accs_email_settings($type);

	$mail = new PHPMailer(); 
	$mail->IsSMTP(); // telling the class to use SMTP
    $mail->SMTPDebug = $settings['mail-debug'];
    $mail->SMTPAuth = $settings['mail-auth'];
    $mail->SMTPSecure = $settings['mail-secure'];
    $mail->Host = $settings['mail-host'];
    $mail->Port = $settings['mail-port'];
    $mail->Username = $settings['mail-username'];
    $mail->Password = $settings['mail-password'];
    $mail->SetFrom($settings['mail-from'], $settings['mail-from-name']);
    $mail->Subject = $settings['mail-subject'];
    $mail->AltBody = $settings['mail-alt-body'];


	$mail->ClearAddresses(); //clears anything in the 'to' field
	$mail->AddAddress('jeremiah.campbell@meantheory.com', 'Jeremiah Campbell');

	$html = email_html();
	$mail->MsgHTML($html);

	echo $html;

	if (!$mail->Send()){
		//
	}
}

send_email();

?>

 

